<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var removeDigit = function (number, digit) {
      let ans = '0'
      for (let i = 0; i < number.length; i++) {
        if (number[i] === digit) {
          const sub = number.slice(0, i) + number.slice(i + 1)
          if (sub > ans) {
            ans = sub
          }
        }
      }
      return ans
    };
  </script>
</body>

</html>